﻿using B.Auth.APi.Application.Command.Users;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;

namespace B.Auth.APi.Application.CommandHand
{
    public class GetCityCommandHand : IRequestHandler<GetCityCommand, ApiResult<List<City>>>
    {
        private readonly IBaseRepository<City> db;

        public GetCityCommandHand(IBaseRepository<City> db)
        {
            this.db = db;
        }

        public Task<ApiResult<List<City>>> Handle(GetCityCommand request, CancellationToken cancellationToken)
        {
            var resukt = new ApiResult<List<City>>();
            var list = db.GetAll().Where(x=>x.provinceid==request.pid).ToList();
            resukt.data= list;
            return Task.FromResult(resukt);
        }
    }
}
